//
//  ViewController.swift
//  NumberDemo
//
//  Created by cailei on 2022/7/12.
//

import UIKit

class ViewController: UIViewController {

    var numberInt: Int = 0
    var numberDouble: Double = 0.0
    var step: Int = 1
    
    @IBOutlet weak var label: UILabel!
    
    @IBOutlet weak var button: UIButton!
    
    override func viewDidLoad() {
        super.viewDidLoad()
        updateUI()
    }

    func updateUI () {
        self.label?.text = "Int:\(numberInt)\nDouble:\(numberDouble)"
        let title = step > 0 ? "+1" : "-1"
        self.button?.setTitle(title, for:.normal)
    }
    
    @IBAction func clickButton(_ sender: Any) {
        numberInt += step
        numberDouble += Double(step)
        if numberInt == 10 || numberInt == 0 {
            step = -step
        }
        updateUI()
    }
    
}

